Fix race conditions involving setenv, gmtime, localtime, asctime.
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 2 May 2012 23:25:46 +0000 (16:25 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 2 May 2012 23:25:46 +0000 (16:25 -0700)
commitc591cad83ebbbd77ff50d566c13289e89cf1a22e
treef8e7f27fea3eadc4934361486565dd5e69c65f50
parent7fcc9e83b81413297c1ac9123a83372f8693c1d6
Fix race conditions involving setenv, gmtime, localtime, asctime.

Without this fix, interrupts could mess up code that uses these
nonreentrant functions, since setting TZ invalidates existing
tm_zone or tzname values, and since most of these functions return
pointers to static storage.
* editfns.c (format_time_string, Fdecode_time, Fencode_time)
(Fcurrent_time_string, Fcurrent_time_zone, Fset_time_zone_rule):
Grow the critical sections to include not just invoking
localtime/gmtime, but also accessing these functions' results
including their tm_zone values if any, and any related TZ setting.
(format_time_string): Last arg is now struct tm *, not struct tm **,
so that the struct tm is saved in the critical section.  All
callers changed.  Simplify allocation of initial buffer, partly
motivated by the fact that memory allocation needs to be outside
the critical section.
src/ChangeLog
src/editfns.c